package org.squabble.domain;

import java.io.Serializable;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity(name = "tag")
@Table(name = "TAG")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Tag extends AbstractType implements Serializable {

	private static final long serialVersionUID = 2811977323684389588L;

	@Column(name = "DISABLED")
	private boolean disabled;

	@OneToMany
	@JoinColumn(name = "TAG_ID")
	private Set<CommentTag> commentTags = new LinkedHashSet<CommentTag>();

	@ManyToMany
	@JoinTable(name = "ARTICLE_TAG", joinColumns = { @JoinColumn(name = "TAG_ID") }, inverseJoinColumns = { @JoinColumn(name = "ARTICLE_ID") })
	private Set<Article> articles = new LinkedHashSet<Article>();

	public boolean isDisabled() {
		return disabled;
	}

	public void setDisabled(boolean disabled) {
		this.disabled = disabled;
	}

	public Set<Article> getArticles() {
		return articles;
	}

	public void setArticles(Set<Article> articles) {
		this.articles = articles;
	}

	public Set<CommentTag> getRemarkTags() {
		return commentTags;
	}

	public void setRemarkTags(Set<CommentTag> commentTags) {
		this.commentTags = commentTags;
	}

	public Set<CommentTag> getCommentTags() {
		return commentTags;
	}

	public void setCommentTags(Set<CommentTag> commentTags) {
		this.commentTags = commentTags;
	}

}
